import { IsArray, IsNotEmpty, IsNumber, IsOptional, IsString, Max, MaxLength, Min, MinLength } from "class-validator";
import PaginationDto from "src/dto/pagination.dto";
import { Merchant } from "src/entities/Merchant";

class CommonDto extends Merchant{
    @MaxLength(15, {message : '商户名称最长15个字符'})
    @MinLength(2, {message : '商户名称最少2个字符'})
    @IsNotEmpty({message : '请填写商户名称'})
    @IsString({message : '数据非法'})
    merchantName:string;


    @Max(100, {message : '分成比例最大100'})
    @Min(0, {message : '分成比例最小0'})
    @IsNumber()
    @IsOptional()
    profitRate:string;

    @Max(100, {message : '提现费率最大100'})
    @Min(0, {message : '提现费率最小0'})
    @IsNumber()
    @IsOptional()
    withdrawalRate:string;

    @IsArray()
    @IsOptional()
    roles:number[];

    @MaxLength(15, {message : ''})
    @IsString({message : '数据非法'})
    @IsOptional()
    contact:string;

    @MaxLength(20, {message : ''})
    @IsString({message : '数据非法'})
    @IsOptional()
    phone:string;

    @Max(1000000, {message : ''})
    @Min(0, {message : ''})
    @IsNumber({allowNaN : false}, {message : '数据非法'})
    @IsOptional()
    provinceId:number;

    @Max(1000000, {message : ''})
    @Min(0, {message : ''})
    @IsNumber({allowNaN : false}, {message : '数据非法'})
    @IsOptional()
    cityId:number;

    @Max(1000000, {message : ''})
    @Min(0, {message : ''})
    @IsNumber({allowNaN : false}, {message : '数据非法'})
    @IsOptional()
    districtId:number;

    @MaxLength(50, {message : ''})
    @IsString({message : '数据非法'})
    @IsOptional()
    address:string;

    @MaxLength(100, {message : ''})
    @IsString({message : '数据非法'})
    @IsOptional()
    remark:string ;
}

export class AddMerchantDto extends CommonDto{
    @MaxLength(20, {message : '登录账号最长20个字符'})
    @MinLength(6, {message : '登录账号最少6个字符'})
    @IsNotEmpty({message : '请填写登录账号'})
    @IsString({message : '数据非法'})
    account:string;

    @MaxLength(20, {message : '登录密码最长20个字符'})
    @MinLength(6, {message : '登录密码最少6个字符'})
    @IsNotEmpty({message : '请填写登录密码'})
    @IsString({message : '数据非法'})
    password:string;
}

export class EditMerchantDto extends CommonDto{
    
}


export class MerchantListDto extends PaginationDto {
    @IsString()
    @IsOptional()
    merchantName:string;

    @IsString()
    @IsOptional()
    account:string;
}